#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main()
{
    int n, i, x, y, f,j;
    scanf("%d", &n);
    for (i = 0; i < n; i++)
    {
        scanf("%d %d", &x, &y);
        f = 0;
        for (j = x; j <= y; j++)
        {
            if (j % 7 == 1 && j % 3 == 2)
            {
                f = 1;
                printf("%d ", j);
            }
        }
        if (f == 0) printf("none");
        printf("\n");
    }
    return 0;
}
